// 路由配置文件
import React from "react";
import { useRoutes, Navigate } from "react-router-dom";
import { MenuItem } from "@/types/router";
import Lazy from './lazy'


export const routeItem: MenuItem[] = [
    {
        type: 'item',
        label: "登录",
        key: '/login',
        path: '/login',
        hidden: true,
        meta: {
            releas: true,
        },
        element: Lazy(React.lazy(() => import("@/views/login")))
    },
    {
        type: 'item',
        label: "",
        key: '/',
        path: '/',
        hidden: false,
        meta: {
        },
        element: Lazy(React.lazy(() => import("@/views/layout"))),
        children: [{
            type: 'item',
            label: "首页",
            key: 'index',
            path: 'index',
            hidden: false,
            meta: {
            },
            element: Lazy(React.lazy(() => import("@/views/index")))
        }, {
            type: 'item',
            label: "电子卷宗",
            key: 'layout',
            path: 'layout',
            hidden: false,
            meta: {
            },
            children: [{
                type: 'item',
                label: "卷宗列表",
                key: 'layout/home',
                path: 'home',
                hidden: false,
                meta: {
                },
                element: Lazy(React.lazy(() => import("@/views/child1"))),
            }, {
                type: 'item',
                label: "布局子二",
                key: 'layout/user',
                path: 'user',
                hidden: false,
                meta: {
                },
                element: Lazy(React.lazy(() => import("@/views/child2"))),
            }]
        },]
    },
    {
        type: 'item',
        label: "*",
        key: '*',
        path: '*',
        hidden: true,
        meta: {
            releas: true,
        },

        element: <Navigate to='/404' />
    },
    {
        type: 'item',
        label: "404",
        key: '404',
        path: '/404',
        hidden: true,
        meta: {
            releas: true,
        },
        element: Lazy(React.lazy(() => import("@/views/404"))),
    },
]

const GetRouters = () => {
    const routes = useRoutes(routeItem);
    return routes;
}
export default GetRouters;

